package com.duoec.dw.lineage.service.analyser.commend;

import com.duoec.dw.lineage.dto.SqoopCommendArgument;
import com.duoec.dw.lineage.exceptions.LineageAnalyseException;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author xuwenzhen
 */
@Service
public class HcatalogTableCommendLineAnalyser extends BaseCommendLineAnalyser {
    /**
     * 用于检查的起始字段串，如果命中后就会执行
     *
     * @return 起始字段串
     */
    @Override
    public String getStart() {
        return "hcatalog-table ";
    }

    /**
     * 分析
     *
     * @param importDto 血缘关系数据
     * @param line      需要处理的行
     */
    @Override
    public void analyse(SqoopCommendArgument importDto, String line) {
        String tableName = line.substring(getStart().length()).trim();
        if (StringUtils.isEmpty(tableName)) {
            throw new LineageAnalyseException("无法解析: targetDatabase，" + line);
        }
        importDto.setHiveTable(tableName);
    }
}
